#include "udp_server.hpp"
#include <memory>
#include "User.hpp"

int main(int argc, char* argv[])
{
    ENABLE_CONSOLE_LOG_STRATEGY();
    if (argc != 2)
    {
        std::cout << "Please use for ./server_udp + port!!" << std::endl;
        Die(USE_ERROR);
    }

    std::shared_ptr<UserManage> um = std::make_shared<UserManage>();

    std::shared_ptr<Udp_server> server = std::make_shared<Udp_server>();

    server->Init();
    server->Register([&um](InetAddr& in){um->AddUser(in);}, 
                    [&um](int fd,std::string message){um->Route(fd,message);},
                    [&um](InetAddr& out){um->Delete(out);});
    server->Start();
    return 0;
}